const {ccclass, property} = cc._decorator;

@ccclass
export default class More extends cc.Component {


    protected hasMore = true;
    protected hasMoreText = '更多>>'
    protected notMoreText = '暂无更多'
    protected hasMoreColor = '#ffffff'
    protected notMoreColor = '#999999'

    protected callback = null


    protected start() {
        this.node.on(cc.Node.EventType.TOUCH_START, () => {
            if (this.hasMore && typeof this.callback === 'function') {
                this.callback()
            }
        }, this)
    }

    public setHasMore(val = true) {
        this.hasMore = val
        const label = this.node.getChildByName('value')
        label.active = false;
        const color = val ? this.hasMoreColor : this.notMoreColor
        const text = val ? this.hasMoreText : this.notMoreText
        label.getComponent(cc.Label).string = text
        label.color = cc.Color.fromHEX(cc.color(), color)
        label.active = true;
    }

    public getCallback() {
        return this.callback
    }

    public setClickCallback(callback) {
        this.callback = callback
    }
}
